package com.forehope;

import com.actionsoft.bpms.bo.engine.BO;
import com.actionsoft.bpms.bpmn.engine.model.run.delegate.ProcessInstance;
import com.actionsoft.bpms.bpmn.engine.model.run.delegate.TaskInstance;
import com.actionsoft.bpms.commons.database.RowMap;
import com.actionsoft.bpms.schedule.IJob;
import com.actionsoft.bpms.util.DBSql;
import com.actionsoft.sdk.local.SDK;
import com.actionsoft.sdk.local.api.ProcessExecuteQuery;
import javafx.concurrent.Task;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import java.util.List;

public class testJob1 implements IJob {
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        String []a = {"A","B","C","D"};
        String sql = "select * from test_mail";
        List<RowMap> list = DBSql.getMaps(sql);
        int j = 0;
        for (String name:a){
            for (int i=1;i<5;i++){
                for (int z=0;z<10;z++){
                    ProcessInstance processInstance = SDK.getProcessAPI().createProcessInstance("obj_2b48f7bf168b4a94b448630c6c72f900",(name+i),list.get(j).getString("title"));
                    ProcessExecuteQuery result = SDK.getProcessAPI().start(processInstance);
                    List<TaskInstance> list1 = result.fetchActiveTasks();
                    TaskInstance taskInstance = list1.get(0);
                    SDK.getTaskAPI().completeTask(taskInstance.getId(),(name+i));
                    j = j+1;
                }

            }
        }
    }
}
